package com.javatest.springboot2docker.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.Instant;

@RestController
@SpringBootApplication
public class DemoApplication {
    private static final Logger LOGGER = LoggerFactory.getLogger(DemoApplication.class);

    /**
     * The entry point of application.
     * 1.执行以下命令编译构建工程：
     * mvn clean package -U -DskipTests
     * 2.编译构建完成后确保target目录有jar文件生成；
     * 3.在Dockerfile所在目录执行以下命令构建镜像(请按照您的实际情况调整镜像名)：
     * docker build -t dockerlayerdemo:0.0.1 .
     * 4.执行以下命令创建并启动容器：
     * docker run --rm -p 8080:8080 dockerlayerdemo:0.0.1
     *
     * @param args the input arguments
     */
    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

    @GetMapping("/hello")
    public String hello() {
        LOGGER.info("get request from client");
        return "hello docker:" + Instant.now();
    }
}
